﻿// Copyright richyp 2009
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace Richyp.Bodger.UI {
    public class CategoryRow : DataGridViewRow {
        public string Category { get; set; }

        public Image Image { get; set; }

        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow) {
            //base.Paint(graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow);
            LinearGradientBrush lgb = new LinearGradientBrush(rowBounds,Color.Orange, Color.Yellow,90);
            graphics.FillRectangle(lgb, rowBounds);
            graphics.DrawRectangle(SystemPens.ControlDark, rowBounds);
            string text = this.Category;
            if (text == null) {
                text = "";
            }
            if (text.IndexOf(".") > -1) {
                text = text.Substring(text.IndexOf(".") + 1);           
            }
            int x = rowBounds.X;
            if (Image != null) {
                x += 24;
                graphics.DrawImage(this.Image, rowBounds.X + 1, rowBounds.Y + 1, 20, 20);
            }
            graphics.DrawString(text, SystemFonts.SmallCaptionFont, SystemBrushes.ControlText, x,rowBounds.Y + 3);
        }
    }
}
